package hn.cch.spring_async_call.runner;

import hn.cch.spring_async_call.task.ApiTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * ApplicationRunner
 * CommandLineRunner
 */
@Component
public class ApiRunner implements ApplicationRunner {

    private Logger logger = LoggerFactory.getLogger(ApiRunner.class);

    @Autowired
    private ApiTask apiTask;

    /**
     * 启动执行
     *
     * @param args
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        logger.info("start run");
        // 程序启动触发定时任务执行
        // apiTask.demoTask();
        // 开个线程执行避免阻塞启动
        // new Thread(()->apiTask.demoTask()).start();
    }
}
